package com.zhoux.mongo.util;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class StringUtil {
	private static Log log=LogFactory.getLog(StringUtil.class);
	
	private static final String fileSuffix=".xml";
	
	public static String formatFileName(String fileName) throws Exception{
		if(fileName.endsWith(".xml")){
			return "./"+fileName;
		}else if(fileName.contains(".")){
			log.error("fileName is wrong! please like: dataBaseName.xml or dataBaseName");
			throw new  Exception();
		}else{
			return "./"+fileName+fileSuffix;
		}
	}
	
	public static String getId(){
		return String.valueOf(System.currentTimeMillis());
	}
	
	public static String writeTableTofile(String tableName){
		StringBuilder sb=new StringBuilder();
		sb.append("<table name=\""+tableName+"\">");
		sb.append("\r\n");
		sb.append("</table>");
		return sb.toString();
	}

}
